package com.huiztech.maystall.activity;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;


public class MoreOptionsActivity extends Activity {

	private RelativeLayout findFriendLayout, opinionLayout ,clearCacheLayout,tuisongLayou;
	private AlertDialog dialog;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_more);

		findFriendLayout = (RelativeLayout) findViewById(R.id.more_find_friend_layout);
		findFriendLayout.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(MoreOptionsActivity.this,
						FindFriendActivity.class);
				startActivity(intent);
			}
		});

		opinionLayout = (RelativeLayout) findViewById(R.id.more_opinion_layout);
		opinionLayout.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(MoreOptionsActivity.this,
						OpinionActivity.class);
				startActivity(intent);
			}
		});
		
		clearCacheLayout = (RelativeLayout) findViewById(R.id.more_clear_cache_layout);
		clearCacheLayout.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				clearCache();
			}
		});
		
		tuisongLayou = (RelativeLayout) findViewById(R.id.more_tuisong_layout);
		tuisongLayou.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				tuisongSet();
			}
		});
	}
	
	private void clearCache() {
		dialog = new AlertDialog.Builder(MoreOptionsActivity.this).create();
		dialog.show();
		dialog.getWindow().setContentView(R.layout.clear_cache_dialog);
		dialog.getWindow().findViewById(R.id.clear_cache_cancel_btn)
				.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						dialog.dismiss();
					}
				});

		dialog.getWindow().findViewById(R.id.clear_cache_submit_btn)
				.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						dialog.dismiss();
					}
				});

	}
	
	private void tuisongSet() {
		dialog = new AlertDialog.Builder(MoreOptionsActivity.this).create();
		dialog.show();
		dialog.getWindow().setContentView(R.layout.delete_dialog);
		dialog.getWindow().findViewById(R.id.delete_dialog_cancel_btn)
				.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						dialog.dismiss();
					}
				});

		dialog.getWindow().findViewById(R.id.delete_dialog_submit_btn)
				.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						dialog.dismiss();
					}
				});

	}
	
}
